<template>
  <div class="header-nav">
    <el-breadcrumb separator="/">
      <el-breadcrumb-item v-for="item in crumbs" :key="item.name" :to="{ path: item.path }">
        {{ item.name }}
      </el-breadcrumb-item>
    </el-breadcrumb>
  </div>
</template>

<script setup lang="ts">
import useLoginStore from '@/store/login/login'
import { getCrumbsByPath } from '@/utils/map-menus'
import { computed } from 'vue'
import { useRoute } from 'vue-router'

const loginStore = useLoginStore()
const route = useRoute()

// 计算属性：当依赖的数据发生改变时，会重新计算
// 获取面包屑数据
const crumbs = computed(() => {
  return getCrumbsByPath(route.path, loginStore.userMenu)
})

</script>
<style scoped lang="less">
.header-nav {}
</style>
